package com.ydd.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.ydd.dto.*;
import com.ydd.entity.YddArticle;
import com.ydd.entity.YddUser;
import com.ydd.entity.YddUserData;
import com.ydd.vo.RowInfoVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserArticleMapper extends BaseMapper<YddUserData> {


    /**
     * 用户中心
     * @param userCurrentId
     * @return
     */
    //统计文章发布总数
    Integer selectAll(Integer userCurrentId);
    //统计点赞数
    Integer selectZan(Integer userCurrentId);
    //统计收藏数
    Integer selectCollect(Integer userCurrentId);

    /**
     * 我的文章
     * @param userArticleRequestDTO
     * @return
     */
    Page<YddArticle> pageQuery(UserArticleRequestDTO userArticleRequestDTO,String author);


    /**
     *
     * 我的收藏
     * @param dataListDTO
     * @return
     */
    Page<YddArticle> DataList(DataListDTO dataListDTO);
    //点赞页面
    Page<YddArticle> myZan(DataListDTO dataListDTO,Integer userCurrentId);

    //收藏页面
    Page<YddArticle> myCollect(DataListDTO dataListDTO,Integer userCurrentId);


    /**
     * 取消收藏
     * @param cancelListDTOs
     */
    void cancel(CancelListDTO cancelListDTOs);
    //查找文章对应的信息
    YddArticle selectByUserId(CancelListDTO cancelListDTO,Integer userId);
    //取消点赞或收藏
    void cancelAction(YddArticle yddArticle);
    //点赞或收藏
    /**
     * 修改用户信息
     * @param yddUsers
     */
    void update(YddUser yddUsers);

    /**
     * 上传文章
     * @param yddArticle
     */
    @Insert("INSERT INTO `ydd_article` VALUES (\n" +
            "null,\n" +
            "#{title},\n" +
            "#{author},\n" +
            "#{keywords},\n" +
            "#{description},\n" +
            "#{content},\n" +
            "#{pic},\n" +
            "#{click},\n" +
            "#{ishot},\n" +
            "#{istop},\n" +
            "#{createDate},\n" +
            "#{updateDate},\n" +
            "#{cateid},\n" +
            "#{tags},\n" +
            "#{status},\n" +
            "#{lovenum},\n" +
            "#{userId},\n" +
            "#{defaultData}\n" +
            "  ) ;\n" +
            "\n")
    void InsertOne(YddArticle yddArticle);
    //通过id查找对应的作者并输出
    String selectAuthor(Integer userId);
    //通过id查找对应的状态并输出
    Integer selectStatus(Integer userId);
    /**
     * 删除文章
     * @param id
     * @return
     */
    @Delete("delete from  ydd_article where id = #{id}")
    void del(Long id);

    /**
     * 修改文章
     * @param yddArticle
     */
    void edit(YddArticle yddArticle);

    /**
     * 根据用户id获取author
     * @param userCurrentId
     * @return
     */
    @Select("select * from ydd_article where user_id = #{userCurrentId}")
    List<YddArticle> selectOrder(Integer userCurrentId);
    @Select("select * from ydd_user_data where article_id = #{articleId} and user_id = #{userId} and type = #{type}")
    YddUserData selectByDate(YddUserData yddUserData);

}
